home *** CD-ROM | disk | FTP | other *** search
- unit UserAPI;
-
- interface
-
- uses
- DB;
-
- procedure AddDBUser(DB: TDatabase;
- UserName,
- Password,
- FirstName,
- LastName: string;
- MustChangePassword: Boolean;
- PasswordLifespan: Integer);
-
- procedure EditDBUser(DB: TDatabase;
- UserName,
- Password,
- FirstName,
- LastName: string;
- MustChangePassword: Boolean;
- PasswordLifespan: Integer);
-
- implementation
-
- uses
- SysUtils, DBTables, FmMain;
-
- function DelimitedStr(S: string): string;
- begin
- Result := '''' + S + '''';
- end;
-
- function BoolToChar(B: Boolean): Char;
- begin
- if B then Result := 'Y' else Result := 'N';
- end;
-
- procedure AddDBUser(DB: TDatabase;
- Username,
- Password,
- FirstName,
- LastName: string;
- MustChangePassword: Boolean;
- PasswordLifespan: Integer);
- begin
- with TQuery.Create(nil) do
- try
- DatabaseName := DB.DatabaseName;
- SQL.Add('execute AddUser ');
- SQL.Add(DelimitedStr(Username) + ',');
- SQL.Add(DelimitedStr(Password) + ',');
- SQL.Add(DelimitedStr(FirstName) + ',');
- SQL.Add(DelimitedStr(LastName) +',');
- SQL.Add(IntToStr(PasswordLifespan) + ',');
- SQL.Add(BoolToChar(MustChangePassword));
- ExecSQL;
- finally
- Free;
- end;
- end;
-
- procedure EditDBUser(DB: TDatabase;
- Username,
- Password,
- FirstName,
- LastName: string;
- MustChangePassword: Boolean;
- PasswordLifespan: Integer);
- begin
- with TQuery.Create(nil) do
- try
- DatabaseName := DB.DatabaseName;
- SQL.Add('execute EditUser ');
- SQL.Add(DelimitedStr(Username) + ',');
- SQL.Add(DelimitedStr(Trim(Password)) + ',');
- SQL.Add(DelimitedStr(FirstName) + ',');
- SQL.Add(DelimitedStr(LastName) +',');
- SQL.Add(IntToStr(PasswordLifespan) + ',');
- SQL.Add(BoolToChar(MustChangePassword));
- ExecSQL;
- finally
- Free;
- end;
- end;
-
- end.
-